const EasterEggsHook = (function () {
    let holder = { times: 0, timestamp: new Date ().getTime () };
    let timeout = 500, click_times = 5, callback = function () {};

    document.addEventListener ('click', function (e) {
        let now = new Date ().getTime ();
        if (now - holder.timestamp > timeout) {
            // 已超时，重置
            holder.times     = 0;
            holder.timestamp = now;
        } else if (holder.times >= click_times) {
            callback ();
        } else {
            holder.times ++;
            holder.timestamp = now;
        }
    });

    return {
        add : function (options) {
            if ('timeout' in options) {
                timeout = options.timeout;
            }
            if ('clickTimes' in options) {
                click_times = options.clickTimes;
            }
            if (('callback' in options) && (typeof options.callback === 'function')) {
                callback = options.callback;
            }
        }
    };
})();
export default EasterEggsHook;